import {reqGetCateGoryList,reqGetBannerList,reqGetFloorList} from '../../api'
// home模块的仓库
const actions = {
    // 通过API接口调用数据
    // 获取三级联动数据
   async categoryList({commit}) {
        let res = await reqGetCateGoryList()
        if (res.code == 200)
           commit('CATEGORYLIST',res.data)
    },
     // 获取首页轮播图数据
     async getBannerList({commit}){
        let res = await reqGetBannerList()
        if(res.code ===  200){
            commit("BANNERLIST",res.data)
        }
    },
    // 获取Floor楼层数据
    async getFloorList({ commit }) {
        let res = await reqGetFloorList()
        if (res.code == 200) {
            commit('FLOORLIST',res.data)
        }
}
}
const mutations = {
    CATEGORYLIST(state, categoryList) {
        categoryList.pop()
        state.categoryList=categoryList
    },
    BANNERLIST(state, bannerList) {
        state.bannerList=bannerList
    },
    FLOORLIST(state, floorList) {
        state.floorList=floorList
    }
}
const state = {
    // 三级联动数据
    categoryList: [],
    // 轮播图图片数据
    bannerList: [],
    // 楼层（floor）数据
    floorList:[]
}
const getters = {}

export default {
    actions,
	mutations,
    state,
    getters
}